﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BussinesLayer.Appointments;
using ModelLayer;

namespace ViewLayer.Appointments
{
    public partial class CancelAppointmentView : Form
    {
        MedAgendaEntities entities = new MedAgendaEntities();
        AppointmentRegistrationController appointmentController = new AppointmentRegistrationController();
        
        private bool cancel = false;
        private string accesionNumber;

        public CancelAppointmentView()
        {
            InitializeComponent();
        }

        public bool Cancel
        {
            get { return cancel; }
            set { cancel = value; }
        }

        public CancelAppointmentView(string accesionNumber)
        {
            InitializeComponent();
            this.accesionNumber = accesionNumber;
        }

        private void buttonCancelCancelingAppointment_Click(object sender, EventArgs e)
        {
            textBoxCancelComment.Clear();
            cancel = true;
            this.Close();
        }

        private void buttonAceptCancelingAppointment_Click(object sender, EventArgs e)
        {
            appointmentController.CancelVisit(this.accesionNumber, textBoxCancelComment.Text, comboBoxCancelReason.SelectedValue.ToString());
            this.Close();
        }

        private void CancelAppointmentView_Load(object sender, EventArgs e)
        {
            comboBoxCancelReason.DataSource = (from c in entities.OrderCancelReasonEnum_ select c).OrderBy(c=>c.Value_).ToList();
            
        }
    }
}
